package ebuy.com.config;

import com.alibaba.druid.support.logging.LogFactory;
import ebuy.com.util.RespBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.rmi.runtime.Log;

@ControllerAdvice
public class Handleexception {
    private Logger logger = LoggerFactory.getLogger(Handleexception.class);
    //出现错误进行 返回
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public RespBean exceptionHander(Exception e){
        logger.info("错误是"+e.toString());

        return RespBean.failure("出现错误",e.getMessage());
    }
}
